// let myHeadContent = document.querySelector("h1");
// myHeadContent.textContent = "11Hello world !!!";

// let iceCream = "chocolate";
// if (iceCream === "chocolate") {
//   alert("我最喜欢巧克力冰淇淋了。");
// } else {
//   alert("但是巧克力才是我的最爱呀……");
// }


// document.querySelector("html").addEventListener("click", () => {
//     alert("i am click");
// })


// 切换头像
let myImage = document.querySelector("img");
myImage.onclick = function () {
    let mysrc = myImage.getAttribute("src");
    if (mysrc == "images/aa.jpeg") {
        myImage.setAttribute("src", "images/bb.png");
    } else {
        myImage.setAttribute("src", "images/aa.jpeg");
    }
}

// 切换用户
let myButton = document.querySelector("button");
let myHead = document.querySelector("h1");

function setUserName() {
    let myName = prompt("请输入你的名字？");
    if (!myName) {
        setUserName();
    } else {
        localStorage.setItem("name", myName);
        myHead.textContent = "哈哈改名了，" + myName;
    }
}

if(!localStorage.getItem("name")) {
    setUserName();
} else {
    let storeName = localStorage.getItem("name");
    myHead.textContent = "哈哈改名了，" + storeName;
}

myButton.onclick = function() {
    setUserName();
}